package com.example.dreamlist2.goal;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.text.TextPaint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.example.dreamlist2.R;
import com.example.dreamlist2.todo.TodoItem;

import java.util.List;

import cn.bmob.v3.datatype.BmobDate;

public class HabitAdapter extends BaseAdapter {
    private List<HabitItem> list;
    private Context context;

        public HabitAdapter(Context context, List<HabitItem> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public HabitItem getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //设置该条的文字展示
        String content;//内容
        int times;//已打卡次数
        HabitItem habit = getItem(position);
        content = habit.getContent();
        times = habit.getTimes();
        //LayoutInflater inflater = LayoutInflater.from(context);
        @SuppressLint("ViewHolder") View view = LayoutInflater.from(context).inflate(R.layout.habit_item, parent,false);
        TextView habit_list_cont = view.findViewById(R.id.habit_list_cont);
        TextView habit_times = view.findViewById(R.id.habit_list_times);
        habit_list_cont.setText(habit.getContent());
        habit_times.setText(habit.getStringTimes());

        habit_list_cont.setTextColor(Color.BLACK);
        TextPaint tp = habit_list_cont.getPaint();
        tp.setFakeBoldText(true);

        return view;
    }
}
